import openpyxl
import random

"""
生成10以内的加减法
"""


def generCacl(number, filePath):
    wb = openpyxl.Workbook()
    sheet = wb.active

    number = number + 1
    a = 1

    # 加
    for i in range(1, number):
        for j in range(1, number):
            print("{}+{}=\t".format(i, j), flush=True)
            sheet.cell(a, 1).value = "{}+{}=".format(i, j)
            a += 1

    # 减
    for i in range(1, number):
        for j in range(1, number):
            if j >= i:
                print("{}-{}=\t".format(j, i), flush=True)
                sheet.cell(a, 1).value = "{}-{}=".format(j, i)
                a += 1

    wb.save(filePath)


if __name__ == '__main__':
    generCacl(10, "F:/Download/test1.xlsx")
